package com.cbs.android.component.weather.weatherinterface.constant;

/**
 * Created by broche on 6/9/16.
 */
public enum WindLevel {
    L0(0), L1(1), L2(2), L3(3), L4(4), L5(5), L6(6), L7(7), L8(8), L9(9), L10(10), L11(11), L12(12), UNKNOW(99);

    private int value = 0;

    WindLevel(int value) {
        this.value = value;
    }

    public static WindLevel valueOf(int value) {
        switch (value) {
            case 0:
                return L0;
            case 1:
                return L1;
            case 2:
                return L2;
            case 3:
                return L3;
            case 4:
                return L4;
            case 5:
                return L5;
            case 6:
                return L6;
            case 7:
                return L7;
            case 8:
                return L8;
            case 9:
                return L9;
            case 10:
                return L10;
            case 11:
                return L11;
            case 12:
                return L12;
            default:
                return UNKNOW;
        }
    }

    public static WindLevel fromSpeed(double speed) {
        if (speed < 0.3) {
            return L0;
        } else if (speed < 1.6) {
            return L1;
        } else if (speed < 3.4) {
            return L2;
        } else if (speed < 5.5) {
            return L3;
        } else if (speed < 8.0) {
            return L4;
        } else if (speed < 10.8) {
            return L5;
        } else if (speed < 13.9) {
            return L6;
        } else if (speed < 17.2) {
            return L7;
        } else if (speed < 20.8) {
            return L8;
        } else if (speed < 24.5) {
            return L9;
        } else if (speed < 28.5) {
            return L10;
        } else if (speed < 32.7) {
            return L11;
        } else {
            return L12;
        }
    }

    public int getValue() {
        return this.value;
    }
}
